﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="辅料挂帐情况.aspx.cs" Inherits="syc.Sale.辅料挂帐情况" %>

<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<link rel="stylesheet" href="jquery.checkbox.css" />
<link rel="stylesheet" href="jquery.safari-checkbox.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.checkbox.min.js"></script>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input:checkbox:not([safari])').checkbox();
        $('input[safari]:checkbox').checkbox({ cls: 'jquery-safari-checkbox' });
        $('input:radio').checkbox();
    });
						
</script>
<form id="form1" runat="server">
<asp:Label ID="SelectedID" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
UpdateCommand="UPDATE [采购材料合同] SET [挂账金额]=@挂账金额,[发票金额]=@发票金额 WHERE [采购材料合同].[ID]=@ID" >
                   <UpdateParameters>
                        <asp:Parameter Name="挂帐金额" Type="Decimal" />
                        <asp:Parameter Name="发票金额" Type="Decimal" />      
                    
                        <asp:Parameter Name="ID" Type="Int32" />
                    </UpdateParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="select 0 as ID,'全部' as 名称 union SELECT [ID], [名称] FROM [辅料供货单位]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="select 0 as ID,'全部' as 品名 union SELECT ID,品名 from 物料品种 where 大宗=1"></asp:SqlDataSource>

<div id="wintop" class="wintop">辅料合同执行情况</div>
<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="辅料采购合同查询">
合同编号：<asp:TextBox ID="BianHao" runat="server" Width="140" CssClass="textbox"></asp:TextBox>
<span style="display:inline-block;width:80px;text-align:right;">合同年度：</span><asp:DropDownList
    ID="NianDu" runat="server" Width="120">
    <asp:ListItem Value="0">全部</asp:ListItem>
    <asp:ListItem Value="2008">2008</asp:ListItem>
    <asp:ListItem Value="2009">2009</asp:ListItem>
    <asp:ListItem Value="2010">2010</asp:ListItem>
    <asp:ListItem Value="2011">2011</asp:ListItem>
    <asp:ListItem Value="2012">2012</asp:ListItem>
    <asp:ListItem Value="2013">2013</asp:ListItem>
    <asp:ListItem Value="2014">2014</asp:ListItem>
    <asp:ListItem Value="2015">2015</asp:ListItem>
    <asp:ListItem Value="2016">2016</asp:ListItem>
    <asp:ListItem Value="2017">2017</asp:ListItem>
    <asp:ListItem Value="2018">2018</asp:ListItem>
    <asp:ListItem Value="2019">2019</asp:ListItem>
    <asp:ListItem Value="2020">2020</asp:ListItem>
    </asp:DropDownList>
    
<span style="display:inline-block;width:60px;text-align:right;">季度：</span><asp:DropDownList
    ID="JiDu" runat="server" Width="80">
    <asp:ListItem Value="0">全部</asp:ListItem>
    <asp:ListItem Value="1">1 季度</asp:ListItem>
    <asp:ListItem Value="2">2 季度</asp:ListItem>
    <asp:ListItem Value="3">3 季度</asp:ListItem>
    <asp:ListItem Value="4">4 季度</asp:ListItem>
    </asp:DropDownList>
<br />
原料类别：<asp:DropDownList ID="LeiBie" runat="server" Width="140px" 
        DataSourceID="SqlDataSource3" DataTextField="品名" DataValueField="ID">

</asp:DropDownList>
<span style="display:inline-block;width:80px;text-align:right;">供货单位：</span><asp:DropDownList ID="GongHuo" runat="server" Width="120" 
        DataSourceID="SqlDataSource2" DataTextField="名称" DataValueField="ID"></asp:DropDownList>
<span style="display:inline-block;width:20px;text-align:right;"></span>
<asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Query_Click" />
        
<asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Reset_Click" />
</asp:Panel>


 <div class="gridframe">
        <div class="gridview">
        
            <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
	            <tr>
		            <td class="grid-title"><div style="float:left;margin-top:3px;">辅料合同执行情况</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10" >10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList></div>
		        </tr>
		        <tr>
		            <td class="grid-back">
                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID" 
                        DataSourceID="SqlDataSource1" 
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" onselectedindexchanged="GridView1_SelectedIndexChanged">
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>                       
                          <asp:TemplateField HeaderText="编号" SortExpression="编号">
                              <ItemTemplate>
                                   <asp:Label ID="bh" runat="server" Text='<%# Bind("编号") %>'></asp:Label>
                                    </ItemTemplate>
                                   <HeaderStyle CssClass="grid-header" />
                              <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField>  
                            <asp:TemplateField HeaderText="年度" SortExpression="年度 ">
                                <ItemTemplate>
                                    <asp:Label ID="nd" runat="server" Text='<%# Eval("年度") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="季度" SortExpression="季度 ">
                                <ItemTemplate>
                                    <asp:Label ID="jd" runat="server" Text='<%# Eval("季度") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="供货单位" SortExpression="供货单位 ">
                                <ItemTemplate>
                                    <asp:Label ID="ghdw" runat="server" Text='<%# Eval("供货单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>  
                              <asp:TemplateField HeaderText="材料类别" SortExpression="辅料类别 ">
                                <ItemTemplate>
                                    <asp:Label ID="yl" runat="server" Text='<%# Eval("辅料类别") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField> 
                         
                             <asp:TemplateField HeaderText="规格" SortExpression="规格 ">
                                <ItemTemplate>
                                    <asp:Label ID="gg" runat="server" Text='<%# Eval("规格") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField> 
                            
                             <asp:TemplateField HeaderText="数量(吨)" SortExpression="数量">
                                <ItemTemplate>
                                    <asp:Label ID="Label_sl" runat="server" Text='<%# Eval("数量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="单价(元)" SortExpression="单价">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dj" runat="server" Text='<%# Eval("单价") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="金额(元)" SortExpression="金额">
                                <ItemTemplate>
                                    <asp:Label ID="je" runat="server" Text='<%# Eval("金额") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField> 
                              <asp:BoundField DataField="挂账金额"  HeaderText="挂账金额(元)" >
                                <HeaderStyle CssClass="grid-header"/>
                                <ItemStyle CssClass="grid" Width="80px" HorizontalAlign="Right"/>
                            </asp:BoundField> 
                           
                             <asp:BoundField DataField="发票金额"  HeaderText="发票金额(元)" >
                                <HeaderStyle CssClass="grid-header"/>
                                <ItemStyle CssClass="grid" Width="80px" HorizontalAlign="Right"/>
                            </asp:BoundField> 
                              <asp:TemplateField HeaderText="是否完成" SortExpression="是否完成">
                            <ItemTemplate>
                             <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("是否完成") %>' 
                                     ToolTip='<%# Eval("ID") %>' AutoPostBack="True" 
                                     oncheckedchanged="CheckBox1_CheckedChanged" />
                            </ItemTemplate>
                            <ControlStyle CssClass="torf" />
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                            </asp:TemplateField> 
                          
                           
                            
                             <asp:TemplateField ShowHeader="False" >
                                <ItemTemplate>
                                    <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                                        CommandName="Edit" CssClass="smallbutton" Text="编辑" />                                    
                                </ItemTemplate>
                                 <EditItemTemplate>
                                     <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                                         CommandName="Update" CssClass="smallbutton" Text="更新" />
                                     <asp:Button ID="Button2" runat="server" CausesValidation="False" 
                                         CommandName="Cancel" CssClass="smallbutton" Text="取消" />
                                 </EditItemTemplate>
                                <ItemStyle CssClass="smallbutton" />
                            </asp:TemplateField>
                        </Columns>
                        </asp:GridView>
		                
		            </td>
	            </tr>
	             <tr>
	            <td>   
                    <table width="100%">
                        <tr>
                            <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" runat="server" Text="" ToolTip="首页" UseSubmitBehavior="false"
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" runat="server" Text="" ToolTip="上一页"  UseSubmitBehavior="false"
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" />第<asp:TextBox ID="TextBox_Pager" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click" AutoPostBack="true"></asp:TextBox>页<input type="button" class="page-split" /><asp:Label ID="Label_Pages" runat="server"></asp:Label><input type="button" class="page-split" />
                                
                                <asp:Button ID="Button_Pager_Next" runat="server" Text="" ToolTip="下一页"  UseSubmitBehavior="false"
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" runat="server" Text="" ToolTip="末页"  UseSubmitBehavior="false"
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server" Text=""></asp:Label>
                            </td>
                        </tr>
                    </table>

		            </td>
	            </tr>
            </table>
            

        </div>
    </div>
    
    </form>
<script>

    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    setTimeout("document.getElementById('ShuLiang').focus();", 100);

    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = selectRow;
        }
        else if (rows[i].className == "grid-row-selected") {
            //rows[i].onclick = function() { parent.swin2_load('//.aspx?id=<%=this.SelectedID.Text %>', 820, 296); }; 
        }
    }


    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;
        if (e.keyCode == 13) e.keyCode = 9;
    }
    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0,sum3=0;
    var col = 8;
    if (rows[0].cells.length == 14) col = 8;
    for (i = 1; i < rows.length; i++) {
        sum1 += Number(rows[i].cells[col].innerText);
        sum2 += Number(rows[i].cells[col + 1].innerText);
        sum3 += Number(rows[i].cells[col + 2].innerText);
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += "<br> 本页合计(金额合计：" + fixFloatZ(sum1, 3) + " 元 挂帐金额合计：" + fixFloatZ(sum2, 3) + " 元 " + " 发票金额合计：" + fixFloatZ(sum3, 3) + " 元)";
    parent.hidesubmenu(true);
</script>



   



